#ifndef __RECV_HELPER_H__
#define __RECV_HELPER_H__


#include <unordered_map>
#include <functional>

#include "common.h"

class RecvHelper
{
private:
    /* data */
public:
    RecvHelper(/* args */);
    ~RecvHelper();

    void Init(int console_fd, int socket_fd);
    int Recv();
    void PrintConsole(const std::string& msg);
    void Process(int cmd_id, std::string& buff);
    bool CheckCmd(int cmd_id);

    void CommonRet(std::string& pbTy, std::string& buff);
    void LoginRet(std::string& pbTy, std::string& buff);
    void PlayerInfoRet(std::string& pbTy, std::string& buff);
    void EnterDefaultSceneResponse(std::string& pbTy, std::string& buff);
    void SkillRet(std::string& pbTy, std::string& buff);

    void EnterSceneRet(std::string& pbTy, std::string& buff);
    void LeaveSceneRet(std::string& pbTy, std::string& buff);
    void MoveRet(std::string& pbTy, std::string& buff);

public:
    int console_fd_;
    int socket_fd_;

    char recvbuff_[common::MAXLINE];
    unsigned short head_;

    std::unordered_map<int, std::function<void(std::string&, std::string&)>> cmd2func_;
};




#endif  // __RECV_HELPER_H__